class Document {
  final String id;
  final String name;
  final String? namespaceId;
  final int? sortNo;
  final int? permission;
  final List<Document> children;

  Document({
    required this.id,
    required this.name,
    this.namespaceId,
    this.sortNo,
    this.permission,
    this.children = const [],
  });

  factory Document.fromJson(Map<String, dynamic> json) {
    return Document(
      id: json['id'].toString(),
      name: json['name'] as String,
      namespaceId: json['namespaceId']?.toString(),
      sortNo: json['sortNo'] as int?,
      permission: json['permission'] as int?,
      children: (json['children'] as List<dynamic>?)
              ?.map((e) => Document.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }
}
